home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d16 / wc15_b.arc / DDE.WMS < prev    next >
Text File  |  1991-03-22  |  13KB  |  333 lines

  1. ;Super DDE Demo
  2.  
  3. STOP
  4. CLEAR 
  5. excelpath$ = "C:\WINDOWS"
  6. qepath$ = "C:\WINDOWS\QE"
  7.   m1 = ADDBAR
  8.         ADDCOMMAND(m1,2,"&WinComm Menu")
  9.   sm1 = ADDMENU(m1,"DD&E")
  10.         ADDCOMMAND(sm1,3,"&Client Server")
  11.         ADDCOMMAND(sm1,4,"&Excel")
  12.         ADDCOMMAND(sm1,5,"&Q+E")
  13. SHOWBAR(m1)
  14. MACROHALT(1)
  15.  
  16.  
  17.    DIALOGBOX 71, 20, 235, 98, 21, "Dynamic Data Exchange Demo"
  18.       LTEXT 8, 10, 225, 24, "This part of the TOUR will demonstrate WinComm acting both as a DDE Client and as a DDE Server.  The Client Server menu selection requires only WinComm to be installed.  The other "
  19.       LTEXT 8, 34, 230, 16, "selections require Microsoft Excel and Pioneer Software Q+E to be installed and in the path.  If they are not the demo will terminate."
  20.       DEFCANCELBUTTON 91, 69, 50, 14, "&OK"
  21.    DEND
  22. DO i = DIALOG? UNTIL(i != 255)
  23. main_loop:
  24.   i = MENU?
  25.   IF(i==2) GOTO win_return
  26.   ELSE IF(i==3) GOTO clint_ser
  27.   ELSE IF(i==4) GOTO excel
  28.   ELSE IF(i==5) GOTO qpluse
  29. GOTO main_loop
  30.  
  31. ;************************** DDE|Client Server ******************************
  32.  
  33. clint_ser:
  34.  
  35.    DIALOGBOX 87, 20, 201, 129, 21, "WinComm Client Server Demo"
  36.       LTEXT 18, 11, 165, 18, "This demo will start another copy of WinComm and will exchange data with it."
  37.       LTEXT 18, 31, 165, 51, "This WinComm will get the session notes from the other WinComm and then set up an ADVISE on one of its variables.  Double click on the other WinComm and see the variable changing.  When finished watching, close the other WinComm."
  38.       DEFCANCELBUTTON 76, 98, 50, 14, "&OK"
  39.    DEND
  40. DO i = DIALOG? UNTIL(i != 255)
  41.  
  42. ENABLEMENU(m1,2,1)      ;disable menu
  43. ENABLEMENU(sm1,3,1)      
  44. ENABLEMENU(sm1,4,1)      
  45. ENABLEMENU(sm1,5,1)
  46. SHOWBAR(m1)
  47.       
  48. WINMOVE(1,1,638,410)                          ;position and size wincomm
  49.  
  50. a$ = ""
  51. wcpath$ = GETSESSSTR(25)
  52. wcpath$ = wcpath$+"\WINCOMM.EXE"
  53. ddechan = DDEINIT("WINCOMM","DDESERV.WMC")              ;test to see if there is a wincomm there
  54. IF(ddechan==0){                                         ;guess not...
  55.         RUN(wcpath$,"",2)                           ;start one as an icon
  56.         ddechan = DDEINIT("WINCOMM","DDESERV.WMC")      ;same as the other DDEINIT causes WinComm
  57.         IF(ddechan==0){                                 ;to load and run DDESERV macro
  58.                 ALERT("Initaite Failed, result = "+strint(ddechan ))
  59.             SHOW(3)                ;Things are not going well
  60.             GOTO exit
  61.         }
  62. }
  63. DDEREQ(ddechan,a$,"1000")           ;asking for the "notes" string variable of the session file
  64. PRINT("Notes are ["+a$+"]^M^J")     ;DDE session integers and strings are identified using the
  65. a$=""                               ;id's in the macro manual + 1000
  66. DDEADVISE(ddechan,a$,"a$")          ;asks the other wincomm to let this one know when its a$ variable
  67. again:                              ;has changed
  68. i = TIME?+5                             ;
  69. DO                                      ;a test to see when the other wincomm
  70. UNTIL( (NULL(a$)!=1) || (TIME?>i))      ;goes away---if nothing happens in five
  71. IF(TIME?>i){                            ;seconds, shut this sucker down
  72.         SHOW(3)                         ;
  73.         GOTO exit                       ;
  74. }
  75. PRINT(a$+"^M^J")                        ;otherwise print the variable sent from the other wincomm
  76. a$=""
  77.  
  78. goto again
  79.  
  80.  
  81. ;************************* DDE|Excel ***************************************
  82. excel:
  83. CLEAR
  84. chartchan = 0
  85. ENABLEMENU(m1,2,1)      ;disable menu
  86. ENABLEMENU(sm1,3,1)      
  87. ENABLEMENU(sm1,4,1)      
  88. ENABLEMENU(sm1,5,1)      
  89. SHOWBAR(m1)
  90.  
  91.    DIALOGBOX 87, 27, 201, 83, 21, "WinComm Client/Excel Server Demo"
  92.       LTEXT 18, 11, 157, 18, "For this demo to work, Excel must be installed with the the path below."
  93.       DEFPUSHBUTTON 43, 65, 50, 14, "&OK"
  94.       CANCELBUTTON 102, 65, 50, 14, "&Cancel"
  95.       EDIT 19, 47, 157, 12, excelpath$
  96.       LTEXT 19, 33, 45, 9, "Excel Path:"
  97.    DEND
  98. DO dg = DIALOG? UNTIL(dg != 255)
  99. IF(dg == 0) GOTO exit1
  100. a$ = ""
  101.  
  102. ddechan = DDEINIT("EXCEL","Sheet1")     ;now try dde
  103. if(ddechan==0){
  104.     inst = RUN(excelpath$+"\excel.exe","",1)             ;start EXCEL
  105.     if(inst<32){
  106.         ALERT("Problem running EXCEL.  Check path or available memory and re-run.")
  107.         GOTO exit1
  108.     }
  109.     ddechan = DDEINIT("EXCEL"+STRINT(inst),"Sheet1")     ;now try it again
  110.     if(ddechan==0){
  111.         ALERT("Excel Initiate Failed, result = "+strint(ddechan ))
  112.         GOTO exit1
  113.     }
  114. }
  115. WINMOVE(0,240,640,240)                          ;position and size wincomm
  116. syschan = DDEINIT("EXCEL","System")             ;set up a system channel to take control of Excel
  117. DDEEXEC(syschan,"[APP.RESTORE()]")              ;if excel is maximized it must be restored
  118. DDEEXEC(syschan,"[APP.MOVE(0,0)]")              ;to change its size
  119. DDEEXEC(syschan,"[APP.SIZE(480,180)]")          ;which we do here
  120. DDEEXEC(syschan,"[FULL(TRUE)]")                 ;makes sheet1 full size
  121. DDEEXEC(syschan,"[COLUMN.WIDTH(75)]")           ;widens the A column
  122.  
  123. ;the following pokes give instructions for operation of this demo
  124. DDEPOKE(ddechan,"R1C1","This is a demonstration of WinComms Client DDE Macro Capability")
  125. DDEPOKE(ddechan,"R2C1","Excel and WinComm have been positioned on the screen by the WinComm Macro.")
  126. DDEPOKE(ddechan,"R3C1","Cell A5 is set up as an ADVISE to WinComm.  Whatever is typed there will display")
  127. DDEPOKE(ddechan,"R4C1","in the WinComm Window.  Try it!  Type EXIT in A5 to quit or CHART for a chart demo.")
  128.  
  129. DDEADVISE(ddechan,a$,"R5C1")            ;this is where the instructions come from
  130. i = 1
  131. DO SENDSPECKEY(0,0,40) i = i+1 UNTIL(i == 5)    ;move the active cell to A5
  132.  
  133. again1:
  134. a1$ = a$
  135. DO UNTIL(CMP(a1$,a$) != TRUE)                    ;test to see when there is a change in A5
  136. PRINT(a$)                                        ;if there is display it
  137. a$ = UPPERCASE(a$)
  138. IF(CMP(a$,"EXIT"+CHAR(13)+CHAR(10)) == TRUE){    ;test here to see if "exit" has been typed in
  139.         DDEUNADVISE(ddechan,"R5C1")              ;if so shut everything down
  140.         GOTO terminate
  141. }
  142. ELSE IF(CMP(a$,"CHART"+CHAR(13)+CHAR(10)) == TRUE) GOTO chart   ;test here to see if "chart" was typed
  143. GOTO again1                                                     ;if neither, go look for more changes
  144.  
  145. chart:
  146. DDEEXEC(syschan,"[APP.MAXIMIZE()]")     ;maximize excel for full effect
  147. DDEPOKE(ddechan,"R11C2","5/1")          ;put a date value in row 11 collumn 2
  148. i = 1
  149. DO
  150. SENDSPECKEY(0,0,40)                     ;move selected cell
  151. i = i+1                                 ;down
  152. UNTIL(i == 7)                           ;seven positions
  153. SENDSPECKEY(0,0,39)                     ;and right one
  154. i = 1                                   ;to position it at r11c2
  155. DO
  156. SENDSPECKEY(3,0,39)                     ;move the active cell right
  157. i = i+1                                 ;12 positions with the shift
  158. UNTIL(i == 12)                          ;key down--thats what the 3 does
  159.  
  160. DDEEXEC(ddechan,"[DATA.SERIES(1,3,3)]")     ;this data series gives us 12 months
  161. j=0 i=0
  162. DO col = j + 2                                  ;this loop puts some vaules under the 12 months
  163.     DDEPOKE(ddechan,"R12C"+STRINT(col),STRINT(i))
  164.     j=j+1 i=i+100
  165. UNTIL(j == 12)
  166. SENDSPECKEY(3,0,40)                             ;shift down
  167. SENDSPECKEY(3,0,35)                             ;shift --the dates and the values are now selected
  168. DDEEXEC(syschan,"[NEW(2)]")                     ;open a new chart
  169. if(chartchan==0) chartchan = DDEINIT("EXCEL","Chart1")           ;Set up channel to chart
  170. DDEEXEC(syschan,"[GALLERY.LINE(2)]")            ;change to a line chart
  171. DDEEXEC(syschan,"[ATTACH.TEXT(1)]")             ;set up to do title text
  172. SENDSPECKEY(0,0,32)                             ;sets the "edit" check
  173. SENDKEY("Widget Sales")                         ;type it in
  174. SENDSPECKEY(0,0,13)                ;enters the text
  175.  
  176. delay = TIME? + 5
  177. DO UNTIL(delay == TIME?)
  178.  
  179. DDEEXEC(syschan,"[ACTIVATE.NEXT()]")            ;lets go back and look at the sheet
  180.  
  181. j=5 i=300                                       ;this loop modifies some of the numbers
  182. DO
  183.         DDEPOKE(ddechan,"R12C"+STRINT(j),STRINT(i))
  184.         j=j+1  i=i+1000
  185. UNTIL(j == 14)
  186. DDEEXEC(syschan,"[ACTIVATE.NEXT()]")
  187.  
  188.  
  189. DDEEXEC(syschan,"[ATTACH.TEXT(4,1,4)]")         ;some text at data point 4
  190. SENDSPECKEY(0,0,32)
  191. SENDKEY("After Advertising")
  192. SENDSPECKEY(0,0,13)
  193.  
  194. delay = TIME? + 5
  195. DO UNTIL(delay == TIME?)
  196.  
  197. DDETERM(chartchan)
  198. DDEEXEC(syschan,"[ARRANGE.ALL()]")              ;move some things around
  199. DDEEXEC(syschan,"[ACTIVATE.NEXT()]")
  200. SENDSPECKEY(0,0,36)
  201. i = 1
  202. DO
  203.         SENDSPECKEY(0,0,38)
  204.         i = i+1
  205. UNTIL(i == 7)                                   ;reposition the active cell to the advise cell
  206. DDEEXEC(syschan,"[APP.RESTORE()]")
  207.  
  208. GOTO again1                                     ;start looking for some thing else
  209.  
  210. terminate:                                      ;we want to shut things down now
  211. DDETERM(ddechan)
  212. DDEEXEC(syschan,"[CLOSE(FALSE)]")        ; we had a chart ignore excel save
  213. if(chartchan) DDEEXEC(syschan,"[CLOSE(FALSE)]") 
  214. DDEEXEC(syschan,"[QUIT()]")
  215. SHOW(3)
  216. GOTO exit                                       ;lets go back and process the menu bar
  217.  
  218.  
  219. ;******************************** DDE|Q+E **********************************
  220. qpluse:
  221.  
  222. CLEAR            ; clear screen
  223. ENABLEMENU(m1,2,1)      ; disable menu
  224. ENABLEMENU(sm1,3,1)      
  225. ENABLEMENU(sm1,4,1)      
  226. ENABLEMENU(sm1,5,1)      
  227. SHOWBAR(m1)
  228.  
  229.  
  230.    DIALOGBOX 87, 20, 212, 104, 21,  "WinComm Client/Q+E Server Demo"
  231.       LTEXT 8, 18, 198, 33, "For this demo to work, 'Q+E' must be installed and in the path given below.  The default query will select all cities so you can see the entries in the other fields for your own queries."
  232.       CANCELBUTTON 118, 80, 50, 14, "&Cancel"
  233.       DEFPUSHBUTTON 43, 80, 50, 14, "&OK"
  234.       EDIT 13, 63, 188, 12, QEPATH$
  235.       LTEXT 13, 52, 42, 9, "Q+E path:"
  236.    DEND
  237.  
  238. DO dg=DIALOG? UNTIL(dg != 255)
  239. IF(dg==0) GOTO exit1
  240.  
  241. macropath$ = GETSESSSTR(28)
  242. FCLOSE(FOPEN(4096,macropath$+"\QUERY.TXT"))  ;create a null file query.txt
  243. query1$ = macropath$+"\QUERY.TXT"
  244.  
  245. ddechan = DDEINIT("QE","SYSTEM")
  246. IF(ddechan==0){
  247.     inst = RUN(qepath$+"\QE.EXE","",2)
  248.     IF(inst < 32){
  249.         ALERT("Problem running Q+E.  Check path or available memory and re-run.")
  250.         GOTO exit1
  251.     }
  252.     ddechan = DDEINIT("QE","SYSTEM")
  253.     IF(ddechan==0){
  254.         ALERT("Q+E Initiate Failed, result = "+strint(ddechan ))
  255.         GOTO exit1
  256.     }
  257. }
  258.  
  259. WINMOVE(1,1,638,400)        ;position and size wincomm
  260. ACTIVATE            ;give the focus back to WinComm to display dialog box
  261. VAR1$="Fill in Query Form:"
  262. city$ = "%"
  263.    DIALOGBOX 70, 5, 204, 190, 21, "Opportunity Query"
  264.       VTEXT 49, 13, 107, 9, VAR1$
  265.       CTEXT 52, 23, 23, 9, "City:"
  266.       EDIT 11, 33, 110, 12, CITY$
  267.       CTEXT 149, 23, 26, 9, "State:"
  268.       EDIT 143, 32, 40, 12, STATE$
  269.       CTEXT 46, 46, 42, 9, "Specialty:"
  270.       EDIT 11, 55, 110, 12, SPECIALTY$
  271.       CTEXT 147, 46, 31, 9, "Region:"
  272.       EDIT 143, 55, 40, 12, REGION$
  273.       UPDATEPB 19, 90, 65, 14, "&Query"
  274.       CANCELBUTTON 119, 90, 65, 14, "&Cancel"
  275.       STEXT 4, 126, 195, 61, QUERY1$
  276.       CTEXT 75, 110, 58, 9, "Query Results"
  277.       LTEXT 9, 74, 191, 9, "* or % can be used as a 'select all' wildcard."
  278.    DEND
  279.  
  280. again2:
  281. DO dg=DIALOG? UNTIL(dg!=255)
  282.  
  283. IF(dg==100){
  284.     ENABLECTL(0,0)    ENABLECTL(100,0)    ;disable push buttons during query
  285.         b$ = ""
  286.         SUBST("*",CITY$,"%",99)
  287.         SUBST("?",CITY$,"_",99)
  288.         a$="'SELECT CITY,STATE,SPECIALTY FROM "+macropath$+"\OPP.DBF WHERE "
  289.         if(NULL(CITY$)==0) b$= b$+"(City LIKE "+QUOTE(CITY$)+" OR "+"SUBURB_OF LIKE "+QUOTE(CITY$)+") AND "
  290.         if(NULL(STATE$)==0) b$= b$+"State LIKE "+QUOTE(STATE$)+" AND "
  291.         if(NULL(REGION$)==0) b$= b$+"REGION LIKE "+QUOTE(REGION$)+" AND "
  292.         if(NULL(SPECIALTY$)==0) b$= b$+"Specialty LIKE "+QUOTE(SPECIALTY$)+" AND "
  293.         b$ = left(b$,len(b$)-5)
  294.         b$ = UPPERCASE(b$)
  295.         b$ = b$+"'"
  296.         PRINT("^M^J")
  297.         DDEEXEC(ddechan,"[OPEN("+a$+b$+")]")
  298.         PRINT(a$+b$)
  299.         DDEEXEC(ddechan,"[SAVE.TEXT.AS("+"'"+macropath$+"\QUERY.TXT',80,60,FALSE,FALSE)]")
  300.  
  301.         Var1$="Enter New Query"
  302.     ENABLECTL(0,1) ENABLECTL(100,1)        ;re-enable push buttons
  303.     UPDATEDLG(255)
  304.         GOTO again2
  305. }
  306. DDEEXEC(ddechan,"[EXIT()]")
  307. DDETERM(ddechan)
  308. DELETEFILE(macropath$+"\QUERY.TXT")          ;delete file query.txt
  309. SHOW(3)
  310.  
  311.  
  312. exit:
  313. CLEAR
  314. SHOW(1)
  315. exit1:
  316. ENABLEMENU(m1,2,0)                  ;re-enable the menu items
  317. ENABLEMENU(sm1,3,0)
  318. ENABLEMENU(sm1,4,0)
  319. ENABLEMENU(sm1,5,0)
  320. SHOWBAR(m1)
  321. GOTO main_loop                             ;go back to menu bar processing
  322.  
  323.  
  324. ;****** WinComm Menu **
  325. win_return:                         ;somebody wants to go back to wincomms menu
  326. i = GETSESSINT(68)
  327. PUTSESSINT(68,0)            ; disable auto sizing
  328. OPEN("TOUR.WSF","",1)
  329. PUTSESSINT(68,i)            ; disable auto sizing
  330. HALT
  331.  
  332. END
  333.